﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Drawing.Imaging;
using System.Drawing.Printing;
using Microsoft.Reporting.WinForms;

namespace card
{
    public partial class STRefoundForm : Form
    {
        public string TFJE
        {
            get
            {
                return this.txtTFJE.Text.Trim();
            }
        }

        private double f_je;

        public STRefoundForm()
        {
            InitializeComponent();
        }

        public STRefoundForm(double weight, double dj, double je, string jfbz, string tfsj)
            : this()
        {
            this.f_je = je;
            SetDefaultValue(weight, dj, je, jfbz, tfsj);
        }

        private void SetDefaultValue(double weight, double dj, double je, string jfbz, string tfsj)
        {
            this.txtWeight.Text = weight.ToString();
            this.txtDJ.Text = dj.ToString();
            this.txtJFBZ.Text = jfbz;
            this.txtJE.Text = je.ToString();
            this.txtTFSJ.Text = tfsj;

            this.txtTFJE.Text = je.ToString();//退费金额默认为金额
        }

        private bool CheckTFJE()
        {
            double tfje = 0;
            try
            {
                tfje = Convert.ToDouble(this.TFJE);
            }
            catch
            {
                MessageBox.Show("退费金额不是有效的数字！");
                return false;
            }
            if (tfje > this.f_je)
            {
                MessageBox.Show("退费金额不能大于收费金额！");
                return false;
            }
            return true;
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            if (CheckTFJE())
            {
                this.DialogResult = DialogResult.OK;
            }
        }
    }
}
